1. Field of the Invention
The present invention relates to image encoding apparatus and method for encoding image data, and to a medium in which the image encoding method has been stored.
2. Related Background Art
Conventionally, in order to provide an image process apparatus, there has been a technique which is based on prediction encoding. The prediction encoding is achieved by using a series conversion unit for converting image data into a prediction error in prediction converting, and an entropy encoding unit for converting the prediction error outputted from the series conversion unit into code data of which redundancy is more smaller by using an entropy encoding method such as Huffman encoding or the like.
In the prediction encoding, a characteristic in a frequency of occurrence (or generation) of the prediction error is difference for each image. Therefore, in order to improve encoding efficiency, it is desired to perform optimum entropy encoding for each image.
As a method to achieve such entropy encoding, a method is well known in which an encoding process is performed on the basis of two-path structure. In this method, the characteristic in the frequency of occurrence of the prediction error is checked and detected in a first path, the entropy encoding method is determined according to the detected characteristic, and then practical encoding is performed in a second path.
However, it has been rare to use this method because the process becomes complicated, use of a memory increases, and the like. Instead, it has been more frequent to determine the entropy encoding method in accordance with a characteristic of general prediction error series.
In this case, by previously encoding the several images, the characteristic in the frequency of occurrence of the prediction error is detected and then the encoding method is determined based on the detected characteristic.
FIG. 2 shows an example of an image encoding apparatus in the above-described conventional system. In the drawing, reference numeral 201 denotes a buffer, 202 denotes a predictor, 203 denotes a subtracter, 204 denotes a memory, 205 denotes a Huffman encoder, and 206 and 207 denote signal lines.
Also, FIG. 2 shows the example of the image encoding apparatus which performs the prediction encoding by using peripheral pixels as a series converting process which converts the image data into the prediction error, and further performs the Huffman encoding as the encoding process.
In FIG. 2, before the encoding is practically performed, a frequency distribution of the prediction error which has been previously obtained by series-converting the image data representing the several images is checked, and then a Huffman table is formed and stored in the memory 204 in accordance with the checked frequency distribution.
In the case of practically performing the encoding, initially image data x is sequentially inputted from the signal line 206. The buffer 201 stores the image data x inputted from the signal line 206, by two lines. The predictor 202 derives, from the buffer 201, the image data of pixel a positioned immediately before an encoding target pixel and the image data of pixel b positioned before the pixel a by one line (see FIG. 3). Then, the predictor 202 generates a prediction value p by calculating p=(a+b)/2.
The subtracter 203 outputs a differential value e between the image data x of the encoding target pixel and the prediction value p. As described above, the Huffman encoder 205 outputs encoding data corresponding to the differential value e from the signal line 207, by referring to the Huffman table previously stored in the memory 204.
On the other hand, compressing efficiency in the prediction encoding depends on prediction accuracy in the series conversion unit and the encoding method in the entropy encoding unit. In order to improve the prediction accuracy, there is a technique which is so-called an error feedback. In the error feedback, the prediction error corresponding to the difference between an encoding target pixel value and the prediction value is used by the predictor as feedback to correct the prediction error.
For example, there is a method in which a mean value of the prediction error is calculated for each state on the basis of the state of the pixel values of the peripheral pixels of the encoding target pixel, and the calculated mean value is added to the prediction value. By using such the method, the prediction accuracy can be improved (such that numerous "0" of which code lengths are short are generated as the prediction errors), and also entropy can be reduced.
In the image encoding apparatus according to the above-described conventional system, in a case where the image data of such an image, e.g., a CG (computer graphics) image, a limited-color image or the like, as discretely having the pixel value is encoded, it is possible that the frequency of occurrence (or generation) of the prediction error after the above-described series conversion was performed becomes discrete.
In such the case, although the short code length has been allocated as the code length by the entropy encoding, the prediction error which is hardly generated or is not at all generated comes to exist. Therefore, there has been a problem that the compression efficiency is not improved.
On the other hand, in the conventional image process apparatus which utilizes the above-described error feedback, in the case where the data of the image, i.e., the CG image, the limited-color image or the like, consisting of the discrete pixel value is subjected to the entropy encoding, there is some fear that good compression performance can not be obtained.
Hereinafter, this case will be concretely explained.
In case of using simple prediction which does not include division such as pre-predicting, plane predicting or the like, if the error feedback is not used, the prediction error which has been generated from the data of the image consisting of the discrete pixel values has the discrete frequency distribution as shown in FIG. 11A.
However, in the case where the error feedback process is added, the prediction error which is essentially generated discretely is diffused to the prediction error of the peripheral value, whereby the frequency distribution as shown in FIG. 11B appears.
In this case, the entropy becomes larger as compared with the case where the error feedback process is not performed, whereby there is a problem that an encode data quantity dependent on the entropy encoding successively performed becomes larger.
That is, there has been a problem that, if the error feedback process for increasing the compression efficiency by reducing the entropy is performed for the image data of which entropy is originally low, the process increases the entropy instead.